package com.inwavetech.os.tests.util;

import com.inwavetech.os.util.EnumHandler;

import junit.framework.TestCase;

import java.util.HashMap;

/**
 * Created by jgskin on 3/13/14.
 */
public class EnumHandlerTest extends TestCase {
    private EnumHandler enumHandler;

    private enum Enums {
        ONE, TWO, THREE
    }

    public EnumHandlerTest() {
        HashMap<Integer, Enum> config = new HashMap<Integer, Enum>();
        config.put(1, Enums.ONE);
        config.put(2, Enums.TWO);
        config.put(3, Enums.THREE);

        enumHandler = new EnumHandler(config);
    }

    public void testConfiguredValues() throws Exception {
        assertEquals((Object) 1, enumHandler.getId(Enums.ONE));
        assertEquals((Object) 2, enumHandler.getId(Enums.TWO));
        assertEquals((Object) 3, enumHandler.getId(Enums.THREE));

        assertEquals(Enums.ONE, enumHandler.getEnum(1));
        assertEquals(Enums.TWO, enumHandler.getEnum(2));
        assertEquals(Enums.THREE, enumHandler.getEnum(3));
    }

    public void testNullValue() throws Exception {
        assertNull(enumHandler.getId(null));

        assertNull(enumHandler.getEnum(null));
    }
}
